#include "DataReturn.h"

DataReturn::DataReturn()
	:studentId (-1),
	dataPaper(QDate::currentDate()),
	actData(QDate::currentDate()),
	returnData(QDate::currentDate()),
	text(QString()),
	was(false),
	contractId(-1)
{
}
DataReturn::DataReturn(const DataReturn &  data)
{
	this->studentId = data.studentId;
	this->contractId = data.contractId;
	this->dataPaper = data.dataPaper;
	this->actData = data.actData;
	this->returnData = data.returnData;
	this->text = data.text;
	this->was = data.was;
}
DataReturn::~DataReturn()
{
	
}
bool DataReturn::operator ==(const DataReturn &other)
{
	if(this->studentId == other.studentId)
		if(this->contractId == other.contractId)
			return true;
	return false;
}
DataReturn & DataReturn::operator =(const DataReturn &other) 
{
	this->actData = other.actData;
	this->contractId = other.contractId;
	this->dataPaper = other.dataPaper;
	this->returnData = other.returnData;
	this->studentId = other.studentId;
	this->text = other.text;
	this->was = other.was;
	return *this;
}
ViewDataReturn DataReturn::toViewDataReturn(quint32 course)
{
	struct ViewDataReturn record;
	if(record.record->getContractId() != -1)
	{
		record.empty = false;
		ContractList cList;
		StudentList stdList;
		cList.load("XML Files",course);
		stdList.load("XML Files");
		Contract *contract = cList.contract(record.record->getContractId());
		record.contract = contract->getDate();
		record.record = this;
		record._name = stdList.getStudent(this->studentId).getCutoff().getName();
	}
	else
		record.empty = true;
	return record;

}